

using System;

namespace CUtil
{							 /// the first three are defined for use with the event viewer only
							/// the rest are for xml logging
							/// WarningsAndErrors Translates as a event viewer warning
	public enum DebugLevelSet{ All, WarningsAndErrors, Errors, Warning, Note, Important, HighLight, Progress };

	/// <summary>
	/// Summary description for DebugLevel.
	/// Needs to be serializable for when a member of remote class
	/// </summary>
	[Serializable]
	public class DebugLevel
	{
		/// <summary>
		/// keeps track of the current setting so that it is only set in one place
		/// and avoids having to trawl through files to change the settings
		/// </summary>
		public static DebugLevelSet currentLevel;
		
		private DebugLevelSet nDebugLevel;

		public DebugLevel( DebugLevelSet level )
		{

			SetLevel( level );
		}

		private void SetLevel( DebugLevelSet level )
		{

			currentLevel = level;

			if( level == DebugLevelSet.All )
			{
				nDebugLevel = DebugLevelSet.All;
			}
			else if( level == DebugLevelSet.Errors )
			{
				nDebugLevel = DebugLevelSet.Errors;
			}
			else
			{
				nDebugLevel = level;
			}
		}

		public DebugLevelSet Level
		{
			get
			{
				return nDebugLevel;
			}
			set
			{
				SetLevel( value );
			}
		}

		public bool TestDebugLevel( DebugLevelSet level )
		{
			/// if all write it
			if( nDebugLevel == DebugLevelSet.All )
				return true;

			/// if not all must be exact level
			if( nDebugLevel == level )
				return true;

			if( level == DebugLevelSet.WarningsAndErrors || level == DebugLevelSet.Errors )
				return true;

			return false;
		}

	}
}


